// 小说文本处理
const cheerio = require('cheerio');

const abc_bookText = (html) => {
	let text = $1(html)('#content').html();
	return (
		'     ' +
		text.replace(/(&nbsp;|<br>|<\/br>)/g, '').replace(/\n\n/g, `\n     `)
	);
};

const qianbi_bookText = (html) => {
	let $ = $1(html);
	let str = '';
	$('#TextContent p').each((_, item) => {
		str += `     ${$(item).text()}` + '\n';
	});
	return str;
};

function $1(html) {
	return cheerio.load(html);
}

module.exports = {
	abc_bookText,
	qianbi_bookText,
};
